home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML ConsoleMax.sea / XML ConsoleMax / Required / swingall.jar / javax / swing / ButtonGroup.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-07-15  |  1.3 KB  |  56 lines

  1. package javax.swing;
  2.  
  3. import java.io.Serializable;
  4. import java.util.Enumeration;
  5. import java.util.Vector;
  6.  
  7. public class ButtonGroup implements Serializable {
  8.    protected Vector buttons = new Vector();
  9.    ButtonModel selection = null;
  10.  
  11.    public void add(AbstractButton var1) {
  12.       if (var1 != null) {
  13.          this.buttons.addElement(var1);
  14.          if (this.selection == null && var1.isSelected()) {
  15.             this.selection = var1.getModel();
  16.          }
  17.  
  18.          var1.getModel().setGroup(this);
  19.       }
  20.    }
  21.  
  22.    public Enumeration getElements() {
  23.       return this.buttons.elements();
  24.    }
  25.  
  26.    public ButtonModel getSelection() {
  27.       return this.selection;
  28.    }
  29.  
  30.    public boolean isSelected(ButtonModel var1) {
  31.       return var1 == this.selection;
  32.    }
  33.  
  34.    public void remove(AbstractButton var1) {
  35.       if (var1 != null) {
  36.          this.buttons.removeElement(var1);
  37.          if (var1.getModel() == this.selection) {
  38.             this.selection = null;
  39.          }
  40.  
  41.          var1.getModel().setGroup((ButtonGroup)null);
  42.       }
  43.    }
  44.  
  45.    public void setSelected(ButtonModel var1, boolean var2) {
  46.       if (var2 && var1 != this.selection) {
  47.          ButtonModel var3 = this.selection;
  48.          this.selection = var1;
  49.          if (var3 != null) {
  50.             var3.setSelected(false);
  51.          }
  52.       }
  53.  
  54.    }
  55. }
  56.